//
//  EFOrderSumTimeCell.m
//  EnjogFood
//
//  Created by 王芳 on 17/5/14.
//  Copyright © 2017年 wf. All rights reserved.
//

#import "EFOrderSumTimeCell.h"
#import "EFOrderTotalAndTimeItem.h"

@interface EFOrderSumTimeCell ()
@property (strong, nonatomic) UIView *line2;

@property (strong, nonatomic) UILabel *orderSumTipLabel;
@property (strong, nonatomic) UILabel *orderSumLabel;

@property (strong, nonatomic) UILabel *orderTimeLabel;
@end

@implementation EFOrderSumTimeCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

- (void)initUI{
    [self.contentView addSubview:self.line2];
    self.line2.left = 20;
    self.line2.top = 0;
    
    [self.contentView addSubview:self.orderSumTipLabel];
    self.orderSumTipLabel.top = self.line2.bottom + 8;
    [self.contentView addSubview:self.orderSumLabel];
    self.orderSumLabel.top = self.orderSumTipLabel.top;
    
    [self.contentView addSubview:self.orderTimeLabel];
    self.orderTimeLabel.top = self.orderSumTipLabel.bottom + 5;
}

- (void)setObject:(EFOrderTotalAndTimeItem *)item{
    self.orderSumLabel.text = [NSString stringWithFormat:@"￥%@",item.orderTotal];
    [self.orderSumLabel sizeToFit];
    self.orderSumLabel.right = kScreenWidth - 20;
    self.orderSumTipLabel.right = self.orderSumLabel.left - 5;
    
    self.orderTimeLabel.text = [NSString stringWithFormat:@"下单时间：%@",item.orderTime];
    [self.orderTimeLabel sizeToFit];
    self.orderTimeLabel.right = kScreenWidth - 20;
    self.orderTimeLabel.top = self.orderSumLabel.bottom + 14;
}

- (UIView *)line2{
    if (!_line2) {
        _line2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth - 2*20, 1)];
        _line2.backgroundColor = RGBCOLOR(0xececec);
    }
    return _line2;
}

- (UILabel *)orderSumTipLabel{
    if (!_orderSumTipLabel) {
        _orderSumTipLabel = [[UILabel alloc] init];
        _orderSumTipLabel.font = [UIFont systemFontOfSize:15];
        _orderSumTipLabel.textColor = kBlack333;
        _orderSumTipLabel.text = @"订单金额：";
        [_orderSumTipLabel sizeToFit];
    }
    return _orderSumTipLabel;
}

- (UILabel *)orderSumLabel{
    if (!_orderSumLabel) {
        _orderSumLabel = [[UILabel alloc] init];
        _orderSumLabel.font = [UIFont systemFontOfSize:15];
        _orderSumLabel.textColor = RGBCOLOR(0x69ba45);
    }
    return _orderSumLabel;
}

- (UILabel *)orderTimeLabel{
    if (!_orderTimeLabel) {
        _orderTimeLabel = [[UILabel alloc] init];
        _orderTimeLabel.font = [UIFont systemFontOfSize:13];
        _orderTimeLabel.textColor = kBlack999;
        _orderTimeLabel.text = @"下单时间：";
        [_orderTimeLabel sizeToFit];
    }
    return _orderTimeLabel;
}



@end
